/*
============================================================================
 Name        : PdDefine.h
 Author      : Jian(raphyer@hotmail.com)
 Version     :
 Copyright   : GPL
 Description : PdDefine.h - header file
============================================================================
*/

#ifndef PDDEFINE_H
#define PDDEFINE_H


#include <e32std.h>
#include <e32base.h>
#include "dd_define.h"

#define LogLeaveIfError(err)	do {\
    TInt error = err ; \
    if ( error != KErrNone ) { \
    DD_LOG("Trap leave error = %d in file = %s and line = %d", error, __FILE__, __LINE__) ; User::Leave(error) ; } } while(0)

#define LogLeaveIfNull(ptr)	    do {\
    void* p = (void*)(ptr) ; \
    if (p == NULL) { \
    DD_LOG("Trap leave NULL in file = %s and line = %d", __FILE__, __LINE__) ; User::LeaveIfNull(p) ; } } while(0)


#define __ToPtrC16(s)        TPtrC16((const TUint16*)s, User::StringLength((const TUint16*)s))
#define __ToPtrC8(s)         TPtrC8((const TUint8*)s, User::StringLength((const TUint8*)s))
#define __ToPtrC8Data(d,l)   TPtrC8((const TUint8*)d, l)
#define __ToPtr8(s,l)        TPtr8((TUint8*)s, l)
#define __ToPtr16(s,l)       TPtr16((TUint16*)s, l)

#define __doDelete(d)  do {if(d) delete (d); (d) = NULL;} while (0) 

#define __ToTRgb(c)   (TRgb((c).r, (c).g, (c).b, (c).alpha))
#define __ToTPoint(p) (TPoint((p).x, (p).y))
#define __ToTSize(s)  (TSize((s).width, (s).height))
#define __ToTRect(r)  (TRect(__ToTPoint((r).pos), __ToTSize((r).size)))


#endif  /* PDDEFINE_H */

/* End of File */
